package com.springboot.jeesite.common.queue.redismq;

import com.springboot.jeesite.common.utils.SpringContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * CompanyRestController
 *
 * @author xxx
 * @version xxx
 */
@RestController
@RequestMapping(value = "${adminPath}/mq/redisProducer")
public class RedisRestController {
    //http://localhost:8080/admin/mq/redisProducer/sendMessage
    @RequestMapping(value = {"sendMessage"})
    public void sendMessage(@RequestParam(required = false) String message) {

  /*      Thread thread = new Thread() {
            @Override
            public void run() {
                while (true) {
                    List<String> redisList = JedisUtils.getList("redisList");
                    if (redisList != null) {
                        System.out.println("reserve message:" + JedisUtils.getList("redisList"));
                    }
                }
            }
        };
        thread.start();

        List<String> value = new ArrayList<String>();
        JedisUtils.setList("redisList", value, 0);
        for (int i = 0; i < 1000; i++) {
            JedisUtils.listAdd("redisList", "test" + i);
            System.out.println("send message:test" + i);
        }*/

        RedisSender redisSender = SpringContextHolder.getBean(RedisSender.class);

        for (int i = 0; i < 1000; i++) {
            redisSender.sendChannelMess("seckill", "send message:test" + i);
            System.out.println("send message:test" + i);
        }

    }
}
